#include <iostream>
#include <string>
using namespace std;
#include <cstring>
#include <unistd.h>
#define N 103
void process_bar(int cur,int total){
    char bar[N] = {0};
    const char* labels = "|/\\";
    int n = strlen(labels);
    int rate = (int)(((float(cur) / total)*100));
    for (int i = 0; i < rate; i++) bar[i] = '#';
    printf("[%-100s][%d%%][%c]\r",bar,rate,labels[rate%n]);
    fflush(stdout);
}

void DownLoad(){
    int total = 2024;
    int cur = 0;
    int speed = 10;
    float rate = 0.2;
    while(cur < total){
        cur += (speed * rate); 
        if (cur > total) cur = total;
        process_bar(cur,total);
        usleep(2000);
    }    
    printf("\n");
}
int main(){
    DownLoad();
    return 0;
}